package com.softa.common.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.softa.common.dto.SysUserDTO;
import com.softa.common.entity.SysResource;
import com.softa.common.entity.SysUser;
import com.softa.common.sysconfig.support.DataTableRequest;
import com.softa.common.sysconfig.support.LoginRequest;
import com.softa.common.sysconfig.support.Result;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Set;

/**
 * @author hasee
 */
public interface UserService {

    /**
     * 创建用户
     *
     * @param user
     */
    String createUser(SysUser user);

    String updateUser(SysUserDTO sysUserDTO);

    void deleteUser(Long userId);

    /**
     * 修改密码
     *
     * @param userId
     * @param newPassword
     */
    void changePassword(Long userId, String newPassword);


    SysUser findOne(Long userId);

    List<SysUser> findAll();

    /**
     * 根据用户名查找用户
     *
     * @param username
     * @return
     */
    SysUser findByUsername(String username);

    /**
     * 根据用户名查找其角色
     *
     * @param username
     * @return
     */
    Set<String> findRoles(String username);

    /**
     * 根据用户名查找其权限
     *
     * @param username
     * @return
     */
    Set<String> findPermissions(String username);

    Page<SysUserDTO> queryUserByParam(DataTableRequest request);

    Long queryUserTotalByParam(DataTableRequest request);

    List<SysResource> findResourceList(String username);

    SysUser findAdminUser();

    Integer checkusername(SysUser user);

    /**
     * 登录
     *
     * @param loginReq
     * @return
     */
    Result login(HttpServletResponse response, HttpServletRequest request, LoginRequest loginReq);

}
